<?php

use Biz\service\Album\AlbumListService;
use Doraemon\service\User;

class HomePageHeadAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_REGISTER;

    /**
     * @throws \Exception
     */
    public function main()
    {
        $currUid = $this->uid;
        $uid = (int)trim($this->getRequest()->getPost('uid', 0));

        if ($uid == 0) { //如果没有uid参数 则uid默认为当前登录用户uid
            $uid = $currUid;
        } else {
            $userInfo = User::getUser($uid);
            if (!$userInfo) {
                throw new Exception("用户不存在", self::CODE_ERROR_VIEW_TOSTA);
            }
        }
        $list = AlbumListService::getHomePageHead($uid, $currUid);
        $this->setSuccess($list, self::API_CODE_SUCCES);

    }
}